package com.itao.poi.tl;

import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.data.Texts;
import com.deepoove.poi.util.PoitlIOUtils;
import com.itao.poi.tl.util.ResourceUtil;

import java.io.FileOutputStream;
import java.util.HashMap;

/**
 * 文本标签{{lebalName}}
 *
 * @author sjt
 * @Date 2024/10/10 8:54
 */
public class TextLebal {

    public static void main(String[] args) throws Exception {
        XWPFTemplate template = XWPFTemplate.compile(ResourceUtil.getDocxPath("text_template.docx"))
                .render(new HashMap<String, Object>() {{
                            put("name", "Sayi");
                            put("author", Texts.of("Sayi").color("000000").create());
                            put("link", Texts.of("website").link("http://deepoove.com").create());
                            put("anchor", Texts.of("anchortxt").anchor("appendix1").create());
                        }}
                );
        FileOutputStream fos = new FileOutputStream(ResourceUtil.getDocxOutPath("text_template.docx"));
        template.writeAndClose(fos);
        PoitlIOUtils.closeQuietlyMulti(template, fos);
    }
}
